/*
 * Copyright 2011 Clean GWT
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.cleangwt.bootstrap.template.client;

import java.util.List;

import com.cleangwt.bootstrap.client.ui.Navbar;
import com.cleangwt.user.shared.Link;
import com.google.gwt.user.client.ui.Widget;

/**
 * A {@link NavbarAffixedContainer} with a fixed-top {@link Navbar} and a {@link Sidebar} . The main
 * links should be put to sidebar. The navbar is just for some other links or form controls.
 * 
 * @author Jess
 * @version 1.0
 * @since 1.0
 */
public class NavbarAffixedContainer2 extends NavbarAffixedContainer {

  private Sidebar sidebar;

  /**
   * Creates a navbar-affixed page container with the given navbar style and links.
   * 
   * @param navbarStyle the navbar's type style
   * @param links the links
   */
  public NavbarAffixedContainer2(String navbarStyle, List<Link> links) {
    super(navbarStyle, links);
    this.sidebar = new Sidebar(links);
    super.sidebarContainer.add(sidebar);

    sidebar.addCloseHandler(toggleHandler);
    sidebar.addOpenHandler(toggleHandler);
  }

  @Override
  public void setContentPage(String pageName, Widget page) {
    super.setContentPage(pageName, page);
    sidebar.setActivePage(pageName);
  }

}
